package org.example.service;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import org.apache.maven.plugin.logging.Log;
import org.example.dto.ColumnDto;

import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import java.util.Properties;

public interface GenerateCode {
    void execute(Log log, String entity, List<ColumnDto> columnDtoList, Properties properties);

    default void createFile(Log log,String path) throws Exception {
        FileUtil.file(path.substring(0, path.lastIndexOf("/"))).mkdirs();
        FileUtil.file(path).createNewFile();
        log.info(FileUtil.file(path).getPath());
    }

    default void writeContent(Log log,String path,String content) throws Exception {
        FileWriter writer = new FileWriter(path);
        writer.write(content);
        writer.close();
    }
}
